package com.wpp.concurrent.demo4_wait_notify;

import java.util.Random;

/**
 * @author wpp25
 * @date 2021/6/22 21:54
 * @description：
 */
public class Demo4ProduceRunnable2 implements Runnable{

    private Random  random = new Random();

    private Demo4Queue queue;

    private Integer inc;
    public Demo4ProduceRunnable2(Demo4Queue queue,Integer inc) {
        this.queue = queue;
        this.inc = inc;
    }

    @Override
    public void run() {
        while (true) {
            String str = "生产的数据：" +inc;
            queue.put(inc +"");
            System.out.println(str);
            inc++;
            try {
                Thread.sleep(random.nextInt(1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
